package com.zll.test;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class 汽水瓶 {

    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        //System.out.println("输入例子：【输入0退出】");
        while(scanner.hasNext()){
            int n = scanner.nextInt();
            if(n==0){
                break;
            }
            list.add(change(n));
        }
        //System.out.println("输出结果：");
        //System.out.println(list);
        for (Integer integer : list) {
            System.out.println(integer);
        }
    }

    public static int change(int n){
        if(n==0 || n==1){
            return 0;
        }
        if(n==2){
            return 1;
        }
        return n/3+change(n/3+n%3);
    }
}
